package com.jgy.controller;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.jgy.annotation.SetLogValue;
import com.jgy.entity.vo.LogCountVo;
import com.jgy.entity.vo.ShopMesVo;
import com.jgy.service.SystemlogService;
import com.jgy.service.SystemlogexceptionService;
import com.jgy.utils.CommonConstants;
import com.jgy.utils.R;
import com.jgy.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 姜光远
 * @date 2023/4/5 15:29
 */
@RestController
@RequestMapping("/home")
public class HomePageController {
    //试试
    @Autowired
    private SystemlogService systemlogService;
    @Autowired
    private SystemlogexceptionService systemlogexceptionService;

    @SetLogValue(modular = "首页",type = CommonConstants.SELECT, describe = "接口日志统计")
    @GetMapping("/countLog")
    public R<?> countLog() {
       List<LogCountVo> logCountVo =  systemlogService.countLog();
        return R.ok(logCountVo);
    }

    @SetLogValue(modular = "首页",type = CommonConstants.SELECT, describe = "错误日志统计")
    @GetMapping("/countErrorLog")
    @DS("master")
    public R<?> countErrorLog() {
        List<LogCountVo> logCountVo =  systemlogexceptionService.countErrorLog();
        return R.ok(logCountVo);
    }

    @SetLogValue(modular = "首页",type = CommonConstants.SELECT, describe = "商城信息统计")
    @GetMapping("/countShopMes")
    @DS("master")
    public R<?> countShopMes() {
        ShopMesVo shopMesVos =  systemlogexceptionService.countShopMes();
        return R.ok(shopMesVos);
    }

    @SetLogValue(modular = "测试threadlocal",type = CommonConstants.SELECT, describe = "测试threadlocal")
    @GetMapping("/threadlocalTest")
    @DS("master")
    public R<?> threadlocalTest() {
        Map map = UserUtils.get();

        return R.ok(map);
    }
}
